package scream.servlet.empresa;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import scream.excepcion.DAOExcepcion;
import scream.negocio.SeguridadNegocioTipoEmpresa;

//import scream.servlet.cliente.DAOExcepcion;
//import scream.servlet.cliente.RequestDispatcher;
//import scream.servlet.cliente.SeguridadNegocioCliente;
//import scream.servlet.cliente.String;

/**
 * Servlet implementation class RegistrarEmpresa
 */
@WebServlet("/RegistrarEmpresa")
public class RegistrarEmpresa extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistrarEmpresa() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	
		String tipo = request.getParameter("txtTipo");
		String descrip = request.getParameter("txtDescrip");
		
		SeguridadNegocioTipoEmpresa negocio = new SeguridadNegocioTipoEmpresa();

		try {
			negocio.insertarTipoEmpresa(tipo, descrip);
			
			//RequestDispatcher rd = request.getRequestDispatcher("ExitoEmpresa.jsp");
			//rd.forward(request, response);
			//response.sendRedirect("ExitoEmpresa.jsp");
			response.sendRedirect(request.getContextPath()
					+ "/RegistrarTipoEmpresa.jsp");
		} catch (DAOExcepcion e) {
			RequestDispatcher rd = request.getRequestDispatcher("RegistrarTipoEmpresa.jsp");
			rd.forward(request, response);
		}
	
	
	}

}
